<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Whisper: logger.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Whisper
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">logger.h</div>  </div>
</div>
<div class="contents">
<a href="logger_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef __LOGGER_H__</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define __LOGGER_H__ 1</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a><a class="code" href="logger_8h.html#a0d166c9d0c55f3d1070f8ec15cc28cb8">00004</a> <span class="preprocessor">#define COMPATIBILITY_LOGGER 1</span>
<a name="l00005"></a>00005 <span class="preprocessor"></span>
<a name="l00006"></a>00006 <span class="comment">/* log-flags, these are optional */</span>
<a name="l00007"></a><a class="code" href="logger_8h.html#a0905aa6cab396efdb4a49c3141e46f43">00007</a> <span class="preprocessor">#define L_DATE 0x0001 </span><span class="comment">/* append date */</span>
<a name="l00008"></a><a class="code" href="logger_8h.html#a5b553a5ac7d0c7ccf3ba58424f12574f">00008</a> <span class="preprocessor">#define L_TIME 0x0002 </span><span class="comment">/* append time (only used with L_DATE) */</span>
<a name="l00009"></a><a class="code" href="logger_8h.html#a49c483fa87342b86608b66b3ec811f9b">00009</a> <span class="preprocessor">#define L_EXIT 0x0004 </span><span class="comment">/* exit program after log */</span>
<a name="l00010"></a>00010 
<a name="l00011"></a><a class="code" href="logger_8h.html#a449c78681d1f99ca53fd5d317eddaa05">00011</a> <span class="preprocessor">#define L_DATETIME (L_DATE | L_TIME) </span><span class="comment">/* use this if you want L_TIME :) */</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="comment">/* log-levels */</span>
<a name="l00014"></a><a class="code" href="logger_8h.html#abcaffe365dee628fcf9fc90c69d534a1">00014</a> <span class="preprocessor">#define LL_DEBUG 0x0008 </span><span class="comment">/* default */</span>
<a name="l00015"></a><a class="code" href="logger_8h.html#a7b575b32729d592da968625c4c5d2c86">00015</a> <span class="preprocessor">#define LL_WARN 0x0010 </span><span class="comment">/* not critical, maybe important */</span>
<a name="l00016"></a><a class="code" href="logger_8h.html#a470f2a78a65631fc362324a584f71bbc">00016</a> <span class="preprocessor">#define LL_ERR 0x0020 </span><span class="comment">/* maybe critical */</span>
<a name="l00017"></a>00017 
<a name="l00018"></a><a class="code" href="logger_8h.html#a79a8c3bc619431a3e621ce3fa51e5e74">00018</a> <span class="preprocessor">#define LL_EMERG (LL_ERR | L_EXIT | LT_BOTH) </span><span class="comment">/* emergency */</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifdef COMPATIBILITY_LOGGER</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="comment">/* log-targets */</span>
<a name="l00022"></a><a class="code" href="logger_8h.html#a890e3677d4fa05ede29044db17bc03f2">00022</a> <span class="preprocessor">#define LT_LOGFILE 0x0080 </span><span class="comment">/* default */</span>
<a name="l00023"></a><a class="code" href="logger_8h.html#add1216bd027d44f81a9a587003b3a162">00023</a> <span class="preprocessor">#define LT_STDERR 0x0100 </span><span class="comment">/* use stderr instead of logfile */</span>
<a name="l00024"></a><a class="code" href="logger_8h.html#a74a2be1da05c782d0a2ebaf37933f2ce">00024</a> <span class="preprocessor">#define LT_SYSLOG 0x0200 </span><span class="comment">/* log to syslog */</span>
<a name="l00025"></a>00025 <span class="preprocessor">#endif</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span>
<a name="l00027"></a><a class="code" href="logger_8h.html#a90e324a6dc7dc07c1acfa6c2cbc0df9f">00027</a> <span class="preprocessor">#define LT_BOTH (LT_LOGFILE | LT_STDERR) </span><span class="comment">/* use logfile and stderr */</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="ui__constants_8h.html">ui_constants.h</a>&quot;</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="comment">/* initialize the logger, if pFlags != 0, the the given flags are taken as</span>
<a name="l00035"></a>00035 <span class="comment"> * default instead of the system-default ones */</span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifdef COMPATIBILITY_LOGGER</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="keywordtype">int</span> <a class="code" href="logger_8h.html#a47a6c72218dc0f15fa69ee146e247706">init_log</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* pLogFile, <span class="keywordtype">unsigned</span> pFlags);
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="keywordtype">int</span> <a class="code" href="logger_8h.html#a47a6c72218dc0f15fa69ee146e247706">init_log</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pFlags, <span class="keyword">const</span> <span class="keywordtype">char</span>* pLogFile = NULL);
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="comment">/* the loggers&#39; heart, if pFlags != 0, they are added to the default ones.</span>
<a name="l00042"></a>00042 <span class="comment"> * pSource denotes the sender of this log message (i.e. the part of the program,</span>
<a name="l00043"></a>00043 <span class="comment"> * if this can be determined...) */</span>
<a name="l00044"></a>00044 <span class="keywordtype">int</span> <a class="code" href="logger_8h.html#a57d28e64b454287d4f683eed87760242">printl_raw</a>(<span class="keywordtype">bool</span> pConsoleOnly, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pFlags, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, va_list pArgList);
<a name="l00045"></a>00045 <span class="keywordtype">int</span> <a class="code" href="logger_8h.html#a49768d5395227b0881497aaf92facdf4">printl_console</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pFlags, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, ...);
<a name="l00046"></a>00046 <span class="keywordtype">int</span> <a class="code" href="logger_8h.html#ac624d343e4f0d5c5bcac94e889f6ea33">printl</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pFlags, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, ...);
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="comment">/* cleanup the logger, flush buffers, close files, etc. */</span>
<a name="l00049"></a>00049 <span class="keywordtype">int</span> <a class="code" href="logger_8h.html#aa8d5e80fad9f467b4ffa69fe5eaa9914">cleanup_log</a>();
<a name="l00050"></a>00050 
<a name="l00051"></a><a class="code" href="classCLogger.html">00051</a> <span class="keyword">class </span><a class="code" href="classCLogger.html">CLogger</a>
<a name="l00052"></a>00052 {
<a name="l00053"></a>00053         <span class="keyword">public</span>:
<a name="l00054"></a>00054                 <span class="keyword">static</span> <a class="code" href="classCLogger.html">CLogger</a>* <a class="code" href="classCLogger.html#ad8776f2dd99d826c8abfefeb3b42f5e9">getInstance</a>();
<a name="l00055"></a>00055                 <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a0ee90adee3b59f163e53393b378d71f4">destroy</a>();
<a name="l00056"></a>00056 
<a name="l00057"></a>00057                 <span class="comment">/* logging format */</span>
<a name="l00058"></a><a class="code" href="classCLogger.html#a91ca2e7b07bd5276bef55c44dc177e6a">00058</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a91ca2e7b07bd5276bef55c44dc177e6a">LOG_DATE</a>;
<a name="l00059"></a><a class="code" href="classCLogger.html#abdc82e706ad57c2d04ff6bf50037e9af">00059</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#abdc82e706ad57c2d04ff6bf50037e9af">LOG_TIME</a>;
<a name="l00060"></a>00060                 <span class="comment">/* logging output facilities */</span>
<a name="l00061"></a><a class="code" href="classCLogger.html#a771326762f18a149fcc84165ef3f15e6">00061</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a771326762f18a149fcc84165ef3f15e6">LOG_FILE</a>;
<a name="l00062"></a><a class="code" href="classCLogger.html#ac51b5df8ce60910e17d1b7e8a1580d6a">00062</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#ac51b5df8ce60910e17d1b7e8a1580d6a">LOG_STDERR</a>;
<a name="l00063"></a><a class="code" href="classCLogger.html#a9d93427ec2fd0540243c6c525f754352">00063</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a9d93427ec2fd0540243c6c525f754352">LOG_SYSLOG</a>;
<a name="l00064"></a><a class="code" href="classCLogger.html#ad9d2f04cb3a9bd12471275cac841f68d">00064</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#ad9d2f04cb3a9bd12471275cac841f68d">LOG_SOCKET</a>;
<a name="l00065"></a>00065 
<a name="l00066"></a><a class="code" href="classCLogger.html#a3d21b7ecad69d69781f700ecb8c3bbcd">00066</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a3d21b7ecad69d69781f700ecb8c3bbcd">sDefaultFlags</a>;
<a name="l00067"></a>00067 
<a name="l00068"></a>00068                 <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#acbee80c14d7028a509836d3482305cd4">init_log</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pFlags, <span class="keyword">const</span> <span class="keywordtype">char</span>* pLogFile = NULL);
<a name="l00069"></a>00069                 <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#af2dd2d781b56eb540533a07d226b48a2">change_flags</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pFlags);
<a name="l00070"></a>00070                 <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a1db23865918859457a2837c7cffaf1b3">printl_console</a>(<span class="keyword">enum</span> <a class="code" href="ui__constants_8h.html#aa01b2ef0e665c07d46da3a102f120f3c">ELogLevel</a> pLogLevel, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, ...);
<a name="l00071"></a>00071                 <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a775e32655d16a6ac311ae80b00f34a2c">printl</a>(<span class="keyword">enum</span> <a class="code" href="ui__constants_8h.html#aa01b2ef0e665c07d46da3a102f120f3c">ELogLevel</a> pLogLevel, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, ...);
<a name="l00072"></a>00072 <span class="preprocessor">#ifdef COMPATIBILITY_LOGGER</span>
<a name="l00073"></a>00073 <span class="preprocessor"></span>                <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a4f94f0148ca8dacdc368cb7556da86fb">printl_raw</a>(<span class="keywordtype">bool</span> pConsoleOnly, <span class="keyword">enum</span> <a class="code" href="ui__constants_8h.html#aa01b2ef0e665c07d46da3a102f120f3c">ELogLevel</a> pLogLevel, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, va_list pArgList);
<a name="l00074"></a>00074 <span class="preprocessor">#endif</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span>
<a name="l00076"></a>00076         <span class="keyword">private</span>:
<a name="l00077"></a>00077                 <a class="code" href="classCLogger.html#a9bee05627064da478ba32af360b8ef19">CLogger</a>();
<a name="l00078"></a>00078                 <span class="keyword">virtual</span> <a class="code" href="classCLogger.html#ab7006486dce8452e8098c12c3f44c34b">~CLogger</a>();
<a name="l00079"></a>00079                 <a class="code" href="classCLogger.html#a9bee05627064da478ba32af360b8ef19">CLogger</a>(<span class="keyword">const</span> <a class="code" href="classCLogger.html">CLogger</a>&amp; );
<a name="l00080"></a>00080                 <a class="code" href="classCLogger.html">CLogger</a>&amp; <a class="code" href="classCLogger.html#adaa3052d7bf54fa8ca0b1b4cc0b95d10">operator=</a>(<span class="keyword">const</span> <a class="code" href="classCLogger.html">CLogger</a>&amp; );
<a name="l00081"></a>00081 
<a name="l00082"></a><a class="code" href="classCLogger.html#a47756f4d4cf890fbbaf730b7ce5adc1f">00082</a>                 <span class="keywordtype">bool</span> <a class="code" href="classCLogger.html#a47756f4d4cf890fbbaf730b7ce5adc1f">mIsInitialized</a>;
<a name="l00083"></a><a class="code" href="classCLogger.html#a77872b5655a38e2c6ea09beed2e25746">00083</a>                 <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a77872b5655a38e2c6ea09beed2e25746">mFlags</a>;
<a name="l00084"></a><a class="code" href="classCLogger.html#aafd50a2c6dbdfe97a02b3eff95e24a1c">00084</a>                 <span class="keyword">static</span> <a class="code" href="classCLogger.html">CLogger</a>* <a class="code" href="classCLogger.html#aafd50a2c6dbdfe97a02b3eff95e24a1c">sInstance</a>;
<a name="l00085"></a><a class="code" href="classCLogger.html#a6c42ee7358802bc918b241c6f922ba85">00085</a>                 <span class="keyword">static</span> pthread_mutex_t <a class="code" href="classCLogger.html#a6c42ee7358802bc918b241c6f922ba85">sSync</a>;
<a name="l00086"></a><a class="code" href="classCLogger.html#ad2f1dba499e4e0241590c7894e5a1629">00086</a>                 std::ofstream <a class="code" href="classCLogger.html#ad2f1dba499e4e0241590c7894e5a1629">mHandle</a>;
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="preprocessor">#ifndef COMPATIBILITY_LOGGER</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span>                <span class="keywordtype">int</span> <a class="code" href="classCLogger.html#a4f94f0148ca8dacdc368cb7556da86fb">printl_raw</a>(<span class="keywordtype">bool</span> pConsoleOnly, <span class="keyword">enum</span> <a class="code" href="ui__constants_8h.html#aa01b2ef0e665c07d46da3a102f120f3c">ELogLevel</a> pLogLevel, <span class="keyword">const</span> <span class="keywordtype">char</span>* pSource, <span class="keyword">const</span> <span class="keywordtype">char</span>* pFormat, va_list pArgList);
<a name="l00090"></a>00090 <span class="preprocessor">#endif</span>
<a name="l00091"></a>00091 <span class="preprocessor"></span>};
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 <span class="preprocessor">#endif </span><span class="comment">/* __LOGGER_H__ */</span>
<a name="l00094"></a>00094 
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Wed Jan 25 2012 22:00:39 for Whisper by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
